home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: redoWriteLargeSlots.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:58 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "latch.h"
- #include "semaphore.h"
- #include "link.h"
- #include "lsn.h"
- #include "bf.h"
- #include "log.h"
- #include "pool.h"
- #include "volume.h"
- #include "logrecs.h"
- #include "trans.h"
- #include "openlog.h"
- #include "bitmap.h"
- #include "bf_extfuncs.h"
- #include "redo_extfuncs.h"
- #include "redo_intfuncs.h"
- #include "logaction.h"
- #include "util_funcs.h"
- #include "thread_globals.h"
- #include "bf_globals.h"
- #include "log_globals.h"
- #include "sm_macro.h"
- #include "bf_macro.h"
-
-
- /*
- * Rewrite slots to a page -- including appending data
- */
-
- void
- redoWriteLargeSlots (
-
- LOGRECORDHDR *record
- )
- {
-
- PID *pid;
- GROUPLINK *groupLink;
- LGNODE *lgNode;
- SLOTTEDPAGE *slottedPage;
- PAGETYPE pageType;
- PAGESLOT *slotPtr;
- SMALLOBJ *objPtr;
- LRC *pageLRC;
- char *data;
- int slotCount;
- LGWRITEINFO *lgWriteInfo;
-
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_1, ("lsn:%d", record->recordLSN.offset));
-
- /*
- * get a pointer to the page for the record
- */
- pid = &(record->actionPid);
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("pid:%d", pid->page));
-
- /*
- * get pointer to oid, header info
- */
- lgWriteInfo = (LGWRITEINFO*) GET_LOG_IMAGE(record, 0);
-
- /*
- * get a pointer to the new data and its length
- */
- data = GET_LOG_IMAGE(record, 1);
- slotCount = lgWriteInfo->size / sizeof(LGSLOT);
-
- /*
- * See if the operation needs to be redone
- * First see the the node is a root on a slotted page
- */
- if (lgWriteInfo->rootSlot != NIL) {
- pageType = PAGE_SLOTTED;
- } else {
- pageType = PAGE_LARGENODE;
- }
- if (!redoCheckPage(record, &groupLink, pageType)) {
-
- /*
- * don't need to redo
- */
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("dirty page not present"));
- return;
- }
- CHECK_GROUPLINK_MAGIC(groupLink);
-
- /*
- * get a pointer to the large node
- */
- if (lgWriteInfo->rootSlot == NIL) {
- lgNode = (LGNODE *) groupLink->bufFrame;
- pageLRC = &(lgNode->header.lrc);
- CHECK_LARGENODE_MAGIC(lgNode);
- } else {
- /*
- * Root node on slotted page
- */
- slottedPage = (SLOTTEDPAGE *) groupLink->bufFrame;
- slotPtr = GETSLOTPTR(slottedPage, lgWriteInfo->rootSlot);
- objPtr = GETOBJECTPTR(slottedPage, slotPtr);
- lgNode = (LGNODE*) objPtr->data;
- pageLRC = &(slottedPage->header.lrc);
- CHECK_SLOTROOT_MAGIC(lgNode);
- }
-
- if (record->action == LOG_ACTION_APPEND_LARGE_SLOTS) {
- lgNode->header.numSlots += slotCount;
- }
-
- if (record->action == LOG_ACTION_INSERT_LARGE_SLOTS) {
-
- /*
- * Shift slots over to allow for insert
- */
- bcopy(((char*)lgNode->slot) + lgWriteInfo->start,
- ((char*)lgNode->slot)+lgWriteInfo->start+lgWriteInfo->size,
- (lgNode->header.numSlots * sizeof(LGSLOT)) - lgWriteInfo->start );
- lgNode->header.numSlots += slotCount;
- }
-
- /*
- * Perform the redo by writing the slots
- */
- bcopy(data, ((char*)lgNode->slot) + lgWriteInfo->start, lgWriteInfo->size);
-
- /*
- * mark the lrc on the page
- */
- *pageLRC = record->actionLRC;
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("marking new page lrc:%d, ", pageLRC->count));
-
- /*
- * signal the semaphore
- */
- signalSemaphore( &(groupLink->pageHash->semaphore) );
-
- /*
- * unfix the page
- */
- bf_UnfixPage(groupLink, BF_DEFAULT, TRUE);
- }
-